#-*- codeing = utf-8 -*-
#@Time : 2020/11/14 15:41
#@Author : 阳某
#@File : my_wsgi_web_server.py
#@Software : PyCharm



from wsgiref.simple_server import  make_server

def run_server(environ,start_response):
    '''
    当有用户在浏览器访问：http:127.0.0.1:8000/，立即执行该函数并将函数的返回值返回给用户浏览器
    :param environ: 请求相关内容，比如浏览器类型，版本，来源地址，url等
    :param start_response: 响应相关内容
    :return:
    '''
    print('hahahaha')
    print(environ)
    print(start_response)
    start_response('200 OK',[('Content-type','text/html;charset=utf-8')])
    return [bytes('<h1>电脑前的你长得真好看</h1>',encoding='utf-8')]

if __name__ == '__main__':
    httpd = make_server('localhost',8000,run_server)
    httpd.serve_forever()
